package com.fruit.auth.service.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fruit.auth.dao.RoleDao;
import com.fruit.auth.dao.RolePrivilegeDao;
import com.fruit.auth.dao.UserRoleDao;
import com.fruit.auth.model.Privilege;
import com.fruit.auth.model.Role;
import com.fruit.auth.service.RoleService;
import com.fruit.dao.BaseDao;
import com.fruit.service.impl.BaseServiceImpl;

@Service("roleService")
public class RoleServiceImpl extends BaseServiceImpl<Role> implements RoleService
{
	@Resource(name="roleDao")
	private RoleDao roleDao;
	
	@Resource(name="userRoleDao")
	private UserRoleDao userRoleDao;
	
	@Resource(name="rolePrivilegeDao")
	private RolePrivilegeDao rolePrivilegeDao;
	
	@Override
	public List<Privilege> findRolePrivileges(Role role)
	{
		return rolePrivilegeDao.findRolePrivileges(role);
	}

	@Override
	public void updateRolePrivileges(Role role, List<Serializable> privilegeIds)
	{
		rolePrivilegeDao.updateRolePrivileges(role, privilegeIds);
	}
	
	public List<Serializable> findRolePrivilegeIds(Role role)
	{
		return rolePrivilegeDao.findRolePrivilegeIds(role);
	}
	
	public void deleteRole(Role role)
	{
		roleDao.deleteRole(role);
	}
	
	public void deleteRoles(String roleIdsStr)
	{
		roleDao.deleteRoles(roleIdsStr);
	}

	@Override
	public BaseDao<Role> getEntityDao()
	{
		return roleDao;
	}
}
